//
//  VCMy.m
//  MOSAD_HW2_1
//
//  Created by Jason on 2020/10/29.
//  Copyright © 2020 Jason. All rights reserved.
//

#import "VCMy.h"

@interface VCMy ()

@end

@implementation VCMy

@synthesize userName = _userName;
@synthesize email = _email;
@synthesize phoneNum = _phoneNum;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"我的";
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    
    //头像图片
    UIImage * image = [UIImage imageNamed:[NSString stringWithFormat:@"head_portrait.jpg"]];
    
    //添加头像框
    UIImageView * headPortrait = [[UIImageView alloc] initWithImage:image];
    headPortrait.frame = CGRectMake(0, 0, 200, 200);
    //居中显示
    headPortrait.center = CGPointMake(self.view.bounds.size.width/2, 120);
    //圆的半径是loginButton宽的一半
    headPortrait.layer.cornerRadius = headPortrait.frame.size.width / 2;
    //是否进行剪切
    headPortrait.clipsToBounds = YES;
    //设置头像框颜色
    headPortrait.backgroundColor = [UIColor whiteColor];
    
    //设置边框大小
    headPortrait.layer.borderWidth = 1;
    //边框颜色
    headPortrait.layer.borderColor = [[UIColor blackColor] CGColor];
    
    [self.view addSubview:headPortrait];
    
    //添加信息栏
    UIView * informationBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width - 100, 130)];
    informationBar.center = CGPointMake(self.view.bounds.size.width/2, 310);
    informationBar.layer.borderWidth = 1;
    informationBar.layer.borderColor = [[UIColor blackColor] CGColor];
    
    //用户名
    _lbUserName = [[UILabel alloc] init];
    _lbUserName.frame = CGRectMake(10, 10, 80, 30);
    _lbUserName.text = @"用户名:";
    _lbUserName.font = [UIFont systemFontOfSize:18];
    _lbUserName.textAlignment = NSTextAlignmentLeft;
    
    //邮箱
    _lbEmail = [[UILabel alloc] init];
    _lbEmail.frame = CGRectMake(10, 50, 80, 30);
    _lbEmail.text = @"邮箱:";
    _lbEmail.font = [UIFont systemFontOfSize:18];
    _lbEmail.textAlignment = NSTextAlignmentLeft;
    
    //电话
    _lbPhoneNum = [[UILabel alloc] init];
    _lbPhoneNum.frame = CGRectMake(10, 90, 80,30);
    _lbPhoneNum.text = @"电话:";
    _lbPhoneNum.font = [UIFont systemFontOfSize:18];
    _lbPhoneNum.textAlignment = NSTextAlignmentLeft;
    
    //用户名文字框
    _tfUserName = [[UILabel alloc] init];
    _tfUserName.frame = CGRectMake(90, 10, self.view.bounds.size.width-210, 30);
    _tfUserName.text = _userName;
    _tfUserName.font = [UIFont systemFontOfSize:18];
    
    //邮箱文字框
    _tfEmail = [[UILabel alloc] init];
    _tfEmail.frame = CGRectMake(90, 50, self.view.bounds.size.width-210, 30);
    _tfEmail.text = _email;
    _tfEmail.font = [UIFont systemFontOfSize:18];
    
    //电话文字框
    _tfPhoneNum = [[UILabel alloc] init];
    _tfPhoneNum.frame = CGRectMake(90, 90, self.view.bounds.size.width-210, 30);
    _tfPhoneNum.text = _phoneNum;
    _tfPhoneNum.font = [UIFont systemFontOfSize:18];
    
    [informationBar addSubview:_lbUserName];
    [informationBar addSubview:_lbEmail];
    [informationBar addSubview:_lbPhoneNum];
    [informationBar addSubview:_tfUserName];
    [informationBar addSubview:_tfEmail];
    [informationBar addSubview:_tfPhoneNum];
    
    [self.view addSubview:informationBar];
    
    
    //关于栏
    UILabel * about = [[UILabel alloc] initWithFrame:CGRectMake(20, 400, 80, 30)];
    about.text = @"关于";
    about.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:about];
    
    //关于框
    UIView * aboutFrame = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width - 40, 240)];
    aboutFrame.center = CGPointMake(self.view.bounds.size.width/2, 580);
    aboutFrame.layer.borderWidth = 1;
    aboutFrame.layer.borderColor = [[UIColor blackColor] CGColor];
    
    
    UILabel * version = [[UILabel alloc] initWithFrame:CGRectMake(15, 20, 80, 30)];
    version.text = @"版本";
    version.font = [UIFont systemFontOfSize:18];
    UILabel * versionStr = [[UILabel alloc] initWithFrame:CGRectMake(180, 20, 80, 30)];
    versionStr.text = @"v1.0";
    versionStr.font = [UIFont systemFontOfSize:18];
    UILabel * privacyAndCookie = [[UILabel alloc] initWithFrame:CGRectMake(15, 70, 120, 30)];
    privacyAndCookie.text = @"隐私和cookie";
    privacyAndCookie.font = [UIFont systemFontOfSize:18];
    UILabel * cleanCache = [[UILabel alloc] initWithFrame:CGRectMake(15, 130, 120, 30)];
    cleanCache.text = @"清除缓存";
    cleanCache.font = [UIFont systemFontOfSize:18];
    UILabel * synchronization = [[UILabel alloc] initWithFrame:CGRectMake(15, 180, 120, 30)];
    synchronization.text = @"同步";
    synchronization.font = [UIFont systemFontOfSize:18];
    
    [aboutFrame addSubview:version];
    [aboutFrame addSubview:versionStr];
    [aboutFrame addSubview:privacyAndCookie];
    [aboutFrame addSubview:cleanCache];
    [aboutFrame addSubview:synchronization];
    
    [self.view addSubview:aboutFrame];
    
    UIBarButtonItem * btnLogout = [[UIBarButtonItem alloc]initWithTitle:@"退出登录" style:UIBarButtonItemStyleDone target:self action:@selector(pressLogout)];
    self.navigationItem.rightBarButtonItem = btnLogout;
    
    UIBarButtonItem * btnLeft = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStyleDone target:self action:nil];
    self.navigationItem.leftBarButtonItem = btnLeft;
    
}


-(void) pressLogout {
    [self.navigationController popToRootViewControllerAnimated:YES];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
